defmodule Giom.Repo.Migrations.CreateStocks do
  use Ecto.Migration

  def change do
    create table(:stocks,primary_key: false) do
		add :code, :string, size: 40, primary_key: true
		add :name, :string

		add :group_code,  :string
		add :group_code2, :string
		add :group_code3, :string
		add :group_code4, :string
		add :group_code5, :string

		add :barcode,  :string ,size: 35
		add :barcode2, :string, size: 35
		add :barcode3, :string, size: 35
		add :barcode4, :string, size: 35

		add :p_price,  :decimal
		add :p_price2, :decimal
		add :p_price3, :decimal
		add :p_price4, :decimal

		add :s_price,  :decimal
		add :s_price2, :decimal
		add :s_price3, :decimal
		add :s_price4, :decimal

		add :m_unit,  :string,size: 2
		add :m_unit2, :string,size: 2
		add :m_unit3, :string,size: 2
		add :m_unit4, :string,size: 2

		add :pack_type,   :string,size: 2
		add :pack_type2,  :string,size: 2
		add :pack_type3,  :string,size: 2

		add :pack_rate, :decimal 
		add :pack_rate2, :decimal 
		add :pack_rate3, :decimal 

		add :unit_weight, :decimal
		add :type, :string,  size: 1
		add :acc_code, :string,  size: 20

		add :prj_code, :string,  size: 10
		add :prj_code2, :string, size: 10
		add :prj_code3, :string, size: 10
		add :prj_code4, :string, size: 10
		add :prj_code5, :string, size: 10

		add :lock, :string,  size: 1
		
		add :create_date, :utc_datetime
		add :edit_date, :utc_datetime
		
		add :creator, :string
		add :editor, :string
	 
        timestamps()
    end
	create unique_index(:stocks, [:code])
  end
  
end
